
var ws;
function socket() {
    ws = new WebSocket('ws://192.168.137.1:5001/ws');
    ws.onopen = function () {
        //AddPut(text);
        // ws.send("hello");
    }
    ws.onmessage = function (evt) {
        toastr.options = {
 
            closeButton: false,
            debug: false,
            progressBar: false,
            positionClass: "toast-top-right",
            onclick: null,
            showDuration: "300",
            hideDuration: "1000",
            timeOut: "5000",
            extendedTimeOut: "1000",
            showEasing: "swing",
            hideEasing: "linear",
            showMethod: "fadeIn",
            hideMethod: "fadeOut"
        };

        var $toast = toastr['info']('您有一条新信息', evt.data);
    }
    ws.onerror = function (evt) {
    }
    ws.onclose = function () {
    }
}
$('#close').click(function () {
    ws.close();
});